package com.example.controller;

import com.example.pojo.BusNews;
import com.example.pojo.PageBean;
import com.example.pojo.Reservation;
import com.example.pojo.Result;
import com.example.service.ReservationService;
import com.example.service.impl.ReservationServerImpl;
import jakarta.annotation.Nullable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/Reservation")
public class ReservationController {
    @Autowired
    private ReservationServerImpl reservationService;
    @PostMapping("/add")
    public Result addReservation(@RequestBody Reservation reservation){
        log.info("新增预约,关键参数:{}",reservation);
       return reservationService.addReservation(reservation);
    }
    @GetMapping("/page")
    public Result pageList(@ModelAttribute PageBean pageBean, @Nullable @RequestParam("activityName") String name){
        log.info("预约的分页查询,参数pageBean: {} 模糊匹配关键词: {}", pageBean,name);
        return reservationService.pageList(pageBean,name);
    }
    @DeleteMapping("/delete")
    public Result DeleteNusByIds(@RequestParam("ids") List<Integer> ids){
        log.info("根据ids删除预约,参数: {}",ids);
        return reservationService.deleteByIds(ids);
    }
    @PutMapping("/update")
    public Result updateBusNews(@RequestBody Reservation reservation){
        log.info("修改预约,关键参数: {}",reservation);
        return reservationService.updateReservation(reservation);
    }
}
